package com.jzt.b2b;

import com.yvan.druid.DruidAutoConfiguration;
import com.yvan.dsf.DsfConfigurableInitializer;
import com.yvan.dsf.EnableDsfConfiguration;
import com.yvan.spring.autoconfig.RedisCacheAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;

/**
 * Created by luoyifan on 2017/11/21.
 */
@SpringBootApplication(exclude = {
        RedisCacheAutoConfiguration.class,
        DataSourceAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class,
        DruidAutoConfiguration.class
})
@EnableDsfConfiguration
public class DemoMain {

    public static void main(String[] args) throws Exception {

        //String beanName = ManagementFactory.getRuntimeMXBean().getName();
        //org.slf4j.MDC.put("process_id", beanName);

        /**/
        DsfConfigurableInitializer initializer = new DsfConfigurableInitializer(args);

        SpringApplication application = new SpringApplication(DemoMain.class);
        application.addInitializers(initializer);
        String[] argsPlus = initializer.argsPlus();
        application.run(argsPlus);

        /*
        List<String> configPaths = Lists.newArrayList();
        configPaths.add("file:D:/Projects/yvan/yvan-dsf-demo/jzt-b2b-config/logback.xml");
        configPaths.add("file:D:/Projects/yvan/yvan-dsf-demo/jzt-b2b-config/web/logback.xml");
        configPaths.add("file:D:/Projects/yvan/yvan-dsf-demo/jzt-b2b-config/logback-dev.xml");
        configPaths.add("file:D:/Projects/yvan/yvan-dsf-demo/jzt-b2b-config/web/logback-dev.xml");
        //String content = LogBackConfigLoader.mergeLogbackConfigurationString(configPaths, true);
        //System.out.println(content);

        ResourceLoader reader = new DefaultResourceLoader();
        Document t = new DOMDocument();
        Element configuration = new DOMElement("configuration");
        configuration.addAttribute("debug", "true");
        t.setRootElement(configuration);

        for (String v : configPaths) {
            SAXReader saxReader = new SAXReader();
            Document source = saxReader.read(reader.getResource(v).getInputStream());
            for (Element element : (List<Element>) source.getDocument().getRootElement().elements()) {
                configuration.add(element.detach());
            }
        }
        System.out.println(t.asXML());
        */
    }
}
